<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Vue v-html和v-text</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@3"></script>
  </head>
  <body>
    <div id="app">
      <h1>Vue实例</h1>
      <hr />
      <div v-text="txt"></div>
      <hr />
      <div v-html="txt"></div>
    </div>

    <script>
      const app = Vue.createApp({
        data() {
          return {
            txt: `<div class="txt">
                <h1>这是一个标题</h1>
                <hr/>
                <p>这里是一段很长的内容</p>
              </div>`,
          };
        },
      });
      console.log(app);
      app.mount("#app");
    </script>
  </body>
</html>
